package org.example.config;

import lombok.RequiredArgsConstructor;
import org.example.plugins.DynamicInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
@RequiredArgsConstructor
public class MyInterceptorConfig extends WebMvcConfigurationSupport {
    private final DynamicInterceptor dynamicInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        // 将上面自定义好的拦截器添加进去。
        registry.addInterceptor(dynamicInterceptor).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}
